//
//  CCKSubMainHeadModel.m
//  BaiSiBuDeJie
//
//  Created by SuperJJ on 16/8/31.
//  Copyright © 2016年 tsaievan. All rights reserved.
//

#import "CCKSubMainHeadModel.h"
#import "HMNetWorkManager.h"
#import "MineUrlDefine.h"

@implementation CCKSubMainHeadModel

+ (instancetype)subMainHeadModelWithDict:(NSDictionary *)dict
{
    CCKSubMainHeadModel *modle = [CCKSubMainHeadModel new];
    
    [modle setValuesForKeysWithDictionary:dict];
    
    return modle;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

+ (void)downloadDataModelWithThemeId:(NSInteger)themeId andSuccessBlock:(void(^)(CCKSubMainHeadModel *model))successBlock andFailedBlock:(void(^)(NSError *error))failedBlock
{
    
    //http://api.budejie.com/api/api_open.php?a=theme_info&appname=bs0315&asid=6B575223-EB6F-46D2-8488-AFCC82CB4EEB&c=topic&client=iphone&device=ios%20device&from=ios&jbk=0&mac=&market=&openudid=73cfae0dfcb634169e0dc1d95217fc84387a21d7&theme_id=xxx&udid=&ver=4.3
    
    NSString *urlStr = [kSubscribeClickUrl stringByReplacingOccurrencesOfString:@"theme_id=xxx" withString:[NSString stringWithFormat:@"theme_id=%zd",themeId]];
    
    // NSLog(@"%@",urlStr);
    
    [[HMNetWorkManager sharedNetWorkManager] GET:urlStr parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary * _Nullable responseObject)
    {
        NSDictionary *dataDict = responseObject[@"info"];
        
        CCKSubMainHeadModel *model = [CCKSubMainHeadModel subMainHeadModelWithDict:dataDict];
        
        if (successBlock)
        {
            successBlock(model);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)
    {
        if (failedBlock)
        {
            failedBlock(error);
        }
    }];
}

@end
